const util = require('../../utils/util.js'),
  regeneratorRuntime = require('../../utils/runtime.js');
let app = getApp();
const HttpAjax = getApp().getHttpData;
import Toast from '../../components/dist/toast/toast';
Page({
  data: {
    cardnum: '*******'
  },
  onLoad: function() {
    this;
    HttpAjax(app.globalData.url + '/MicroApp/CardData', {}, 'get', app.globalData.headerCookie).then(c => {
      app.globalData.cardid = c.data.Data;
      let d = app.globalData.cardid.replace(/ /g, '');
      10 < d.length ? this.setData({
        cardnum: '*'.padStart(d.length, '*')
      }) : this.setData({
        cardnum: '*'.padStart(10, '*')
      })
    })
  },
  onReady: function() {},
  onShow: function() {
    if (app.globalData.cardid) {
      let a = app.globalData.cardid.replace(/ /g, '');
      10 < a.length ? this.setData({
        cardnum: '*'.padStart(a.length, '*')
      }) : this.setData({
        cardnum: '*'.padStart(10, '*')
      })
    }
  },
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  onReachBottom: function() {},
  showId() {
    let a = app.globalData.cardid.replace(/ /g, '');
    10 < a.length ? this.setData({
      cardnum: a
    }) : this.setData({
      cardnum: (a + '').padStart(10, 0)
    })
  },
  unshowId() {
    let a = app.globalData.cardid.replace(/ /g, '');
    10 < a.length ? this.setData({
      cardnum: '********'.padStart(a.length, '*')
    }) : this.setData({
      cardnum: '*'.padStart(10, '*')
    })
  },
  clearCooker(){
    
    HttpAjax(app.globalData.url + '/Door/RefreshCustomerList', {}, 'post', app.globalData.headerCookie)
      .then(ress => {
        
        
        let res = ress.data;
        console.log(res)
        if (res.result==1){
          Toast('刷新列表数据成功');
          setTimeout(() => {
            Toast.clear()
          }, 2000)
        }
    }).catch(err=>{
      Toast.clear()
    })
  }
});